#include "cppTutorStructure.h"

#include <iostream>

using namespace std;

CcppTutorStructure :: CcppTutorStructure ()
{
}

CcppTutorStructure :: ~CcppTutorStructure ()
{
}
#ifdef SIMPLE_STRUCTURE
void CcppTutorStructure :: m_SimpleStructure ()
{
	struct Structure1 s1, s2;
	s1.c = 'a'; // Select an element using a '.'
	s1.i = 1;
	s1.f = static_cast <float> (3.14);
	s1.d = 0.00093;
	s2.c = 'a';
	s2.i = 1;
	s2.f = static_cast <float> (3.14);
	s2.d = 0.00093;

	cout << s1.c << endl;
	cout << s1.i << endl;
	cout << s1.f << endl;
	cout << s1.d << endl;
	cout << s1.c << endl;
	cout << s1.i << endl;
	cout << s1.f << endl;
	cout << s1.d << endl;
}
#endif //SIMPLE_STRUCTURE

#ifdef TYPEDEF_WITH_STRUCT
void CcppTutorStructure :: m_TypedefWithStructure ()
{
	Structure2 s1, s2;
	s1.c = 'a'; // Select an element using a '.'
	s1.i = 1;
	s1.f = static_cast <float> (3.14);
	s1.d = 0.00093;
	s2.c = 'a';
	s2.i = 1;
	s2.f = static_cast <float> (3.14);
	s2.d = 0.00093;

	cout << s1.c << endl;
	cout << s1.i << endl;
	cout << s1.f << endl;
	cout << s1.d << endl;
	cout << s1.c << endl;
	cout << s1.i << endl;
	cout << s1.f << endl;
	cout << s1.d << endl;
}
#endif //TYPEDEF_WITH_STRUCT

#ifdef POINTERS_TO_STRUCTS
void CcppTutorStructure :: m_PointerToStructure ()
{
	Structure3 s1, s2;
	Structure3* sp = &s1;
	sp->c = 'a';
	sp->i = 1;
	s1.f = static_cast <float> (3.14);
	sp->d = 0.00093;
	sp = &s2; // Point to a different struct object
	sp->c = 'a';
	sp->i = 1;
	s1.f = static_cast <float> (3.14);
	sp->d = 0.00093;
}
#endif //POINTERS_TO_STRUCTS
